package com.nervenets.template.config;

import com.nervenets.general.event.SysLogEventListener;
import com.nervenets.general.service.RedisService;
import com.nervenets.template.event.DataOfUserEventListener;
import com.nervenets.template.service.*;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;

import javax.annotation.Resource;

@EnableAsync
@Configuration
@AllArgsConstructor
@EnableAspectJAutoProxy
@ConditionalOnWebApplication
public class EventListenerConfiguration {
    @Resource
    private final RedisService redisService;
    @Resource
    private final DataOfUserService dataOfUserService;
    @Resource
    private final DataOfGoldService dataOfGoldService;
    @Resource
    private final DataOfMoneyService dataOfMoneyService;
    @Resource
    private final UserService userService;
    @Resource
    private final WealthFlowService wealthFlowService;
    @Resource
    private final RechargeOrderService rechargeOrderService;

    @Bean
    public DataOfUserEventListener dataOfUserEventListener() {
        return new DataOfUserEventListener(
                dataOfUserService,
                userService,
                rechargeOrderService
        );
    }

    @Bean
    public SysLogEventListener sysLogEventListener() {
        return new SysLogEventListener();
    }
}
